package de.justphil.tcg.tcgserver.commons.util;

import java.math.RoundingMode;
import java.text.NumberFormat;

public class MemoryUtil {
	private static final long MEGABYTE = 1024L * 1024L;

	public static String formatBytes(long bytes) {
		long b = bytes / MEGABYTE;
		
		NumberFormat nf = NumberFormat.getInstance();
		nf.setMaximumFractionDigits(2);
		nf.setRoundingMode(RoundingMode.HALF_UP);
		
		return nf.format(b);
	}
}
